package cn.tedu._04mybatis.mapper;

import cn.tedu._04mybatis.pojo.entity.entity.Comment;
import cn.tedu._04mybatis.pojo.entity.vo.CommentVO1;
import org.apache.ibatis.annotations.*;

@Mapper
public interface CommentMapper {
    @Insert(
            "INSERT INTO comment(content,created,user_id,weibo_id) VALUES (#{content},#{created},#{userId},#{weiboId})"
    )
    int insertComment(Comment comment);

    //根据id删除一条评论
    @Delete("DELETE FROM comment WHERE id=#{cid}")
    int deleteCommentById(Long cid);


    //根据id修改评论信息
    @Update("UPDATE comment SET content=#{content},created=#{created},user_id=#{userId},weibo_id=#{weiboId} WHERE id=#{id}")
    int updateCommentById(Comment comment);


    //根据id查询评论的内容，用户id，微博id
    @Select("SELECT id,content,created,user_id,weibo_id FROM comment WHERE id=#{cid}")
    CommentVO1 selectCommentById(Long cid);
}
